package com.bilibili.xzz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bilibili.xzz.entity.User;
import com.bilibili.xzz.mapper.UserMapper;
import com.bilibili.xzz.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    UserMapper userMapper;

    @Override
    public User getUserByNameAndPwd(String name,String password) {
        return userMapper.selectOne(new QueryWrapper<User>().eq("name",name).eq("password",password));
    }

    @Override
    public int setUserByNameAndPwd(User user) {
        return userMapper.insert(user);
    }

    @Override
    public List<User> getUser() {
        return userMapper.selectList(null);
    }

    @Override
    public int deleteUser(String name) {
        return userMapper.delete(new QueryWrapper<User>().eq("name",name));
    }


}
